//
//  ScrollView.swift
//  Candy
//
//  Created by Insect on 2019/3/1.
//  Copyright © 2019 Insect. All rights reserved.
//

import UIKit
import MJRefresh
class ScrollView: UIScrollView {

    override init(frame: CGRect) {
        super.init(frame: frame)
        makeUI()
    }

    required public init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
        makeUI()
    }

    func makeUI() {

    }

    func updateUI() {
        setNeedsDisplay()
    }
}

extension UIScrollView {

    public var refreshHeader: MJRefreshHeader? {
        get { return mj_header }
        set { mj_header = newValue }
    }

    public var refreshFooter: MJRefreshFooter? {
        get { return mj_footer }
        set { mj_footer = newValue }
    }

    public var isTotalDataEmpty: Bool {
        return mj_totalDataCount() == 0
    }
}

public class RefreshHeader: MJRefreshGifHeader {

    /// 初始化
    override public func prepare() {
        super.prepare()

    }
}

public class RefreshFooter: MJRefreshAutoStateFooter {

    /// 初始化
    override public func prepare() {
        super.prepare()
        triggerAutomaticallyRefreshPercent = 0.5
    }
}
